import dayjs from "dayjs";
//import {dayjs} from 'element-plus' 一样的
import { ref,computed , onUnmounted } from "vue";
export const useCountDown = () => {
    const time = ref(0);
    let timer = null;
    const formatTime1 = computed(()=>dayjs.unix(time.value).format('mm分ss秒'))
    const start = (curTime) => {
        time.value = curTime;   
        
        timer = setInterval(() => {
            if (time.value > 0) {
                time.value--;
            }
        }, 1000);
    };
    onUnmounted(() => {
        timer && clearInterval(timer);
    });
    return { formatTime1, start };
};